﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MoveCursor
{
    public class Program
    {        
        static void Main(string[] args)
        {
            MoveCursor();       
        }

        static void MoveCursor()
        {
            int left = 0;
            int top = 0;
            Console.SetCursorPosition(left, top);
            ConsoleKeyInfo key = new ConsoleKeyInfo();                         

            while (true)
            {

            key = Console.ReadKey();

                if (key.Key == ConsoleKey.DownArrow)
                {
                    if (top == 299)
                    {
                        Console.SetCursorPosition(left, top);
                        continue;
                    }
                    top++;
                    Console.SetCursorPosition(left, top);
                }

                if (key.Key == ConsoleKey.UpArrow)
                {
                    if (top == 0)
                    {
                        Console.SetCursorPosition(left, top);
                        continue;
                    }

                    top--;
                    Console.SetCursorPosition(left, top);
                }

                if (key.Key == ConsoleKey.RightArrow)
                {
                    if (left == 79)
                    {
                        Console.SetCursorPosition(left, top);
                        continue;
                    }
                    left++;
                    Console.SetCursorPosition(left, top);
                }

                if (key.Key == ConsoleKey.LeftArrow)
                {
                    if (left == 0)
                    {
                        Console.SetCursorPosition(left, top);
                        continue;
                    }
                    left--;
                    Console.SetCursorPosition(left, top);
                }
            }
        }
    }
}
